/** 分页数据格式 */
export interface PaginationMeta {
  page: number; // 当前页，从 1 开始
  pageSize: number; // 每页条数
  total: number; // 总条数
  pages?: number; // 总页数
}
export class PaginatedDataDto<T = any> {
  list: T[];
  pagination: PaginationMeta;

  constructor(list: T[], pagination: PaginationMeta) {
    this.list = list;
    this.pagination = pagination;
  }

  /* 快速工厂 */
  static of<U>(list: U[], total: number, page: number, pageSize: number) {
    return new PaginatedDataDto(list, {
      page,
      pageSize,
      total,
      pages: Math.ceil(total / pageSize),
    });
  }
}
